package total;

import java.util.Scanner;

public class Ques1818 {
	
	public void go(){
		int[]  dp = new int[1000020];
		Scanner scan = new Scanner(System.in);
		int n,m,k;
		int i;
		while(scan.hasNext()){
			n = scan.nextInt();
			m = scan.nextInt();
			k = Math.max(n, m);
			dp[n] = 1;
			dp[m] = 1;
			for(i = k + 1;i <= 1000010;i++){
				if(i < 20){
					System.out.println("i - n:" + (i - n));
					System.out.println("i - m:" + (i - m));
					System.out.println("i:"+i);
					System.out.println("dp[i - n]:" + dp[i - n]);
					System.out.println("dp[i - m]:" + dp[i - m]);					
				}
				if(dp[i - n] == 1||dp[i - m] == 1)
					dp[i] = 1;
			}
			for(i = 1000010;i>=0;i--){
				if(dp[i] == 0){
					break;
				}
			}
			System.out.println(i);
		}
	}
	
	public static void main(String[] args) {
		new Ques1818().go();
	}
}
